<template>
  <div class="wrap w-friend detail">
    <header>
        <img onclick="javascript :history.back(-1);" src="@/assets/img/r_w.png" alt="" />
        成为合伙人
    </header>
    <div class="head">
        <div class="box">
            <img class="rzImg" src="@/assets/img/rz.jpg" alt="" />
            <div class="headImg"><img src="@/assets/img/headImg.png" alt="" /></div>
            <div class="items clearfix">
                <div class="item">
                    <span>{{hospitalNum}}</span>
                    <p>邀请医院数</p>
                </div>
                <div class="item">
                    <span>{{dealNum}}</span>
                    <p>成交单数</p>
                </div>
            </div>
        </div>
    </div>
    <section>
        <h4>我邀请的医院</h4>
        <ul>
            <li v-for="(item,index) in hospital" :key="index">
                <h3>{{item.company_name}}</h3>
                <p>日期：{{item.add_time}}</p>
            </li>
        </ul>
    </section>
    <div class="copy">
        <div class="con">
            邀请码&nbsp;&nbsp;<span>{{inviteCode}}</span>
            <button type="button" @click="toCopy">复 制</button>
        </div>
    </div>

</div>

</template>
<script>
export default {
  data(){
    return{
        hospitalNum:0, //邀请医院数
        dealNum:0, //邀请医院 成交数
        hospital:[],//邀请的医院
        inviteCode: '',   //邀请码
          
     }
  },
  async created(){
    let user_token = this.getUserToken()
    let re = await this.$axios.post('user/getInviteInfo',{
        user_token:user_token
    })
    if(re.code == 200){
          this.hospitalNum = re.data.hospital_num
          this.dealNum = re.data.deal_num
          this.hospital = re.data.hospital

          this.inviteCode = re.data.invite_code
         
      }      
  },
  
  mounted(){
            
  },
  
  methods:{
    toCopy(){
        let that =this;
        this.$copyText(this.inviteCode).then(function (e) {
            that.$createToast({
              type: 'txt',
              txt: '复制成功',
              time: 1000
            }).show()

        }, function (e) {
          console.log(e)
        })
      }

  }

}

</script>